/*
 * This file is part of aion-unique <aion-unique.com>.
 *
 *  aion-unique is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  aion-unique is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with aion-unique.  If not, see <http://www.gnu.org/licenses/>.
 */
package com.aionemu.gameserver.skillengine.model;

import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlType;

import com.aionemu.gameserver.skillengine.action.Actions;
import com.aionemu.gameserver.skillengine.condition.Conditions;
import com.aionemu.gameserver.skillengine.effect.EffectTemplate;
import com.aionemu.gameserver.skillengine.effect.Effects;

/**
 * @author ATracer, MrPoke
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "skillTemplate", propOrder =
{ "targetProperties", "startconditions", "useconditions", "effects", "actions","dispelInfo" })
public class SkillTemplate
{
	@XmlElement(name = "target_properties")
	protected TargetProperty		targetProperties;
	protected Conditions			startconditions;
	protected Conditions			useconditions;
	protected Effects				effects;
	protected Actions				actions;
	@XmlElement(name = "dispel_info")
	protected DispelInfo			dispelInfo;
	@XmlAttribute(name = "skill_id", required = true)
	protected int					skillId;
	@XmlAttribute(required = true)
	protected String				name;
	@XmlAttribute(required = true)
	protected int					nameId;
	@XmlAttribute
	protected String				stack		= "NONE";
	@XmlAttribute
	protected int					lvl;
	@XmlAttribute(name = "basic_lvl")
	protected int					basicLvl = 0;
	@XmlAttribute(name = "skilltype", required = true)
	protected SkillType				type;
	@XmlAttribute(name = "skillsubtype", required = true)
	protected SkillSubType			subType;
	@XmlAttribute(name = "tslot")
	protected SkillTargetSlot		targetSlot;
	@XmlAttribute(name = "activation", required = true)
	protected ActivationAttribute	activationAttribute;
	@XmlAttribute(required = true)
	protected int					duration;
	@XmlAttribute(name = "cooldown")
	protected int					cooldown;
	@XmlAttribute(name = "penalty_skill_id")
	protected int					penaltySkillId;
	@XmlAttribute(name = "pvp_damage")
	protected int					pvpDamage;
	@XmlAttribute(name = "pvp_duration")
	protected int					pvpDuration;
	@XmlAttribute(name = "chain_skill_prob")
	protected int					chainSkillProb;
	@XmlAttribute(name = "cancel_rate")
	protected int					cancelRate;
	@XmlAttribute(name = "skillset_exception")
	protected int					skillSetException;
	@XmlAttribute
	protected Boolean				stance		= false;
	@XmlAttribute(name = "allow_move")
	protected Boolean				allowMove	= false;

	public TargetProperty getTargetProperties()
	{
		return targetProperties;
	}

	/**
	 * Gets the value of the startconditions property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link Conditions }
	 *     
	 */
	public Conditions getStartconditions()
	{
		return startconditions;
	}

	/**
	 * Gets the value of the useconditions property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link Conditions }
	 *     
	 */
	public Conditions getUseconditions()
	{
		return useconditions;
	}

	/**
	 * Gets the value of the effects property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link Effects }
	 *     
	 */
	public Effects getEffects()
	{
		return effects;
	}

	/**
	 * Gets the value of the actions property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link Actions }
	 *     
	 */
	public Actions getActions()
	{
		return actions;
	}

	/**
	 * Gets the value of the dispelInfo property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link DispelInfo }
	 *     
	 */
	public DispelInfo getDispelInfo()
	{
		return dispelInfo;
	}

	/**
	 * Gets the value of the skillId property.
	 * 
	 */
	public int getSkillId()
	{
		return skillId;
	}

	/**
	 * Gets the value of the name property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link String }
	 *     
	 */
	public String getName()
	{
		return name;
	}

	/**
	 * @return the nameId
	 */
	public int getNameId()
	{
		return nameId;
	}

	/**
	 * @return the stack
	 */
	public String getStack()
	{
		return stack;
	}

	/**
	 * @return the lvl
	 */
	public int getLvl()
	{
		return lvl;
	}

	/**
	 * @return Returns the basicLvl.
	 */
	public int getBasicLvl()
	{
		return basicLvl;
	}

	/**
	 * Gets the value of the type property.
	 * 
	 * @return
	 *     possible object is
	 *     {@link SkillType }
	 *     
	 */
	public SkillType getType()
	{
		return type;
	}

	/**
	 * @return the subType
	 */
	public SkillSubType getSubType()
	{
		return subType;
	}

	/**
	 * @return the targetSlot
	 */
	public SkillTargetSlot getTargetSlot()
	{
		return targetSlot;
	}

	/**
	 * @return the duration
	 */
	public int getDuration()
	{
		return duration;
	}

	/**
	 * @return the activationAttribute
	 */
	public ActivationAttribute getActivationAttribute()
	{
		return activationAttribute;
	}

	public boolean isPassive()
	{
		return activationAttribute == ActivationAttribute.PASSIVE;
	}

	public boolean isToggle()
	{
		return activationAttribute == ActivationAttribute.TOGGLE;
	}

	public boolean isProvoked()
	{
		return activationAttribute == ActivationAttribute.PROVOKED;
	}

	public boolean isActive()
	{
		return activationAttribute == ActivationAttribute.ACTIVE;
	}

	/**
	 * 
	 * @param position
	 * @return EffectTemplate
	 */
	public EffectTemplate getEffectTemplate(int position)
	{
		return effects != null && effects.getEffects().size() >= position ? effects.getEffects().get(position - 1) : null;

	}

	/**
	 * 
	 * @return
	 */
	public int getEffectsDuration()
	{
		return effects != null ? effects.getEffectsDuration() : 0;
	}

	/**
	 * @return the cooldown
	 */
	public int getCooldown()
	{
		return cooldown;
	}

	/**
	 * @return the penaltySkillId
	 */
	public int getPenaltySkillId()
	{
		return penaltySkillId;
	}

	/**
	 * @return the pvpDamage
	 */
	public int getPvpDamage()
	{
		return pvpDamage;
	}

	/**
	 * @return the pvpDuration
	 */
	public int getPvpDuration()
	{
		return pvpDuration;
	}

	/**
	 * @return chainSkillProb
	 */
	public int getChainSkillProb()
	{
		return chainSkillProb;
	}

	/**
	 * @return cancelRate
	 */
	public int getCancelRate()
	{
		return cancelRate;
	}

	/**
	 * @return skillSetException
	 */
	public int getSkillSetException()
	{
		return skillSetException;
	}

	public boolean isStance()
	{
		return stance;
	}

	public boolean isAllowMove()
	{
		return allowMove;
	}

	public boolean hasResurrectEffect()
	{
		return getEffects() != null && getEffects().isResurrect();
	}

	public boolean hasItemHealFpEffect()
	{
		return getEffects() != null && getEffects().isItemHealFp();
	}
}
